<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('cases', function (Blueprint $table) {
            $table->bigIncrements('id');
            // 机构
            $table->integer('organ_id')->nullable(false)->default(0)->comment('机构id');
            // 委案信息
            $table->integer('agency_company_id')->nullable(false)->default(0)->comment('委案公司id');
            $table->integer('agency_product_id')->nullable(false)->default(0)->comment('委案产品id');
            // 案人基础信息
            $table->integer('litigant_id')->nullable(false)->default(0)->comment('委案人信息');
            $table->string('litigant_name', 50)->nullable(false)->default('')->comment('委案人姓名');
            $table->string('litigant_id_card', 50)->nullable(false)->default('')->comment('委案人身份证');
            // 案件信息
            $table->string('case_no', 50)->nullable(false)->default('')->comment('委案编号');
            $table->string('contract_no',50)->nullable(false)->default('')->comment('合同号');
            $table->decimal('capital',10)->nullable(false)->default(0.00)->comment('委案金额');
            $table->decimal('interest',10)->nullable(false)->default(0.00)->comment('利息');
            $table->decimal('late_fee',10)->nullable(false)->default(0.00)->comment('滞纳金');
            $table->string('bank_name')->nullable(false)->default('')->comment('开户行');
            $table->string('bank_card_number')->nullable(false)->default('')->comment('银行卡号');
            $table->dateTime('entrust_start_time')->nullable(false)->comment('委案开始时间');
            $table->dateTime('entrust_end_time')->nullable(false)->comment('委案结束时间');
            $table->dateTime('overdue_date')->nullable(false)->comment('逾期日期');
            $table->dateTime('periods')->nullable(false)->comment('分期期数');
            $table->dateTime('re_periods')->nullable(false)->comment('已还期数');
            $table->enum('case_status',[1,2,3,4,5,6,7])->nullable(false)->default(1)->comment('案件状态 1.待分配 2.已分配 3');
            $table->integer('owner_id')->nullable(false)->default(0)->comment('创建人id');
            $table->enum('status',[1,2])->nullable(false)->default(1)->comment('通用状态 1正常 2已删除');
            $table->dateTime('delete_time')->comment('删除时间');
            // 标签管理
            $table->string('tag_ids')->comment('标签组ids');
            $table->datetimes();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('cases');
    }
};
